{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "a20a2420",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "有限域 GF(4) 的性质 Galois Field:\n",
      "  name: GF(2^2)\n",
      "  characteristic: 2\n",
      "  degree: 2\n",
      "  order: 4\n",
      "  irreducible_poly: x^2 + x + 1\n",
      "  is_primitive_poly: True\n",
      "  primitive_element: x\n",
      "有限域 GF(4) 的元素 [0 1 2 3]\n",
      "有限域 GF(4) 的加法表\n",
      "x + y | 0  1  2  3 \n",
      "------|------------\n",
      "    0 | 0  1  2  3 \n",
      "    1 | 1  0  3  2 \n",
      "    2 | 2  3  0  1 \n",
      "    3 | 3  2  1  0 \n",
      "有限域 GF(4) 的乘法表\n",
      "x * y | 0  1  2  3 \n",
      "------|------------\n",
      "    0 | 0  0  0  0 \n",
      "    1 | 0  1  2  3 \n",
      "    2 | 0  2  3  1 \n",
      "    3 | 0  3  1  2 \n"
     ]
    }
   ],
   "source": [
    "import galois\n",
    "\n",
    "GF4 = galois.GF(4)\n",
    "print(\"有限域 GF(4) 的性质\", GF4.properties)\n",
    "print(\"有限域 GF(4) 的元素\", GF4.elements)\n",
    "\n",
    "print(\"有限域 GF(4) 的加法表\")\n",
    "print(GF4.arithmetic_table(\"+\"))\n",
    "print(\"有限域 GF(4) 的乘法表\")\n",
    "print(GF4.arithmetic_table(\"*\"))\n",
    "\n",
    "## 输出示例\n",
    "# 有限域 GF(4) 的性质 Galois Field:\n",
    "#   name: GF(2^2)\n",
    "#   characteristic: 2\n",
    "#   degree: 2\n",
    "#   order: 4\n",
    "#   irreducible_poly: x^2 + x + 1\n",
    "#   is_primitive_poly: True\n",
    "#   primitive_element: x\n",
    "# 有限域 GF(4) 的元素 [0 1 2 3]\n",
    "# 有限域 GF(4) 的加法表\n",
    "# x + y | 0  1  2  3 \n",
    "# ------|------------\n",
    "#     0 | 0  1  2  3 \n",
    "#     1 | 1  0  3  2 \n",
    "#     2 | 2  3  0  1 \n",
    "#     3 | 3  2  1  0 \n",
    "# 有限域 GF(4) 的乘法表\n",
    "# x * y | 0  1  2  3 \n",
    "# ------|------------\n",
    "#     0 | 0  0  0  0 \n",
    "#     1 | 0  1  2  3 \n",
    "#     2 | 0  2  3  1 \n",
    "#     3 | 0  3  1  2 \n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
